//Dwr推送消息处理
var dwrLinkid;

$(function (){
	//初始化Dwr
	dwr.engine.setActiveReverseAjax(true);
	dwr.engine.setNotifyServerOnPageUnload(true, true);
	dwr.engine.setErrorHandler(function(){});
	
	MyDwrAjax.getLinkid({callback:function(data){
		if(!data){
			dwrLinkid = $.trim(data);
		}
	}});
	
	//Dwr心跳包
	window.setInterval(dwrHeartbeat, 60000);
});

//心跳维持
function dwrHeartbeat(){
	MyDwrAjax.heartbeat({callback:function(data){
		if(!data || $.trim(data) != '1'){
			dwrlinkid = 0;
		}
	}});
}

//消息处理
function __dwrMessage(message){
	if(message.type == 'control'){//控制信息
		var iframeWin = __getIframeWindow('/wlw/yckz/yckz.do');
		if(iframeWin && iframeWin.messageHandler){
			iframeWin.messageHandler.call(null, message.message);
		}
	}
	
}

//获取指定页面对象
function __getIframeWindow(href){
	var iframeWindow;
	$('#iframe_box iframe').each(function(){
		if($(this).attr('data-href') === href){
			iframeWindow = $(this)[0].contentWindow;
			return false;
		}
	});
	return iframeWindow;
}


